﻿using FarmSmartSleep.Common.Domain.EarTage;
using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Organ.API.Application.EarsCommands;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace FarmSmartSleep.Organ.API.Controllers
{
    /// <summary>
    /// 耳标管理控制器--API
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EarsTagController : ControllerBase
    {

        private readonly IMediator mediator;

        public EarsTagController(IMediator mediator)
        {
            this.mediator = mediator;
        }


        /// <summary>
        /// 查询产羔耳标管理信息
        /// </summary>
        /// <param name="request">查询产羔耳标管理信息请求对象</param>
        /// <param name="cancellationToken"></param>
        /// <returns>查询产羔耳标管理信息响应对象</returns>
        [HttpPost]
        public async Task<ResultT<LambEarListDto>> SearchLambEars(LambEarSearchCommand cmd)
        {
            return await mediator.Send(cmd);
        }

        /// <summary>
        /// 获取产羔对应品种信息
        /// </summary>
        /// <param name="cmd">获取产羔对应品种信息请求对象</param>
        /// <returns>获取产羔对应品种信息响应对象</returns>
        [HttpGet]
        public async Task<ResultT<LambBreed>> SearchLambBreed([FromQuery] LambBreedSearchCommand cmd)
        {  return await mediator.Send(cmd); }


        /// <summary>
        /// 获取产羔出生状态
        /// </summary>
        /// <param name="cmd">获取产羔出生状态请求对象</param>
        /// <returns>获取产羔出生状态响应对象</returns>
        [HttpGet]
        public async Task<ResultT<LambBirthdayStatus>> SearchBirthdayStatus([FromQuery] LambBirthdayStatusCommand cmd)
        { return await mediator.Send(cmd);}


        /// <summary>
        /// 批量删除产羔耳标信息
        /// </summary>
        /// <param name="cmd">批量删除产羔耳标信息的编号字符串</param>
        /// <returns>批量删除产羔耳标信息响应对象</returns>
        [HttpDelete]
        public async Task<Result> AllDeleteLambEars(LambEarAllDeletedCommand cmd)
        { return await mediator.Send(cmd);}

        /// <summary>
        /// 添加产羔耳号信息
        /// </summary>
        /// <param name="cmd">添加产羔耳号信息请求对象</param>
        /// <returns>添加产羔耳号信息相应对象</returns>
        [HttpPost]
        public async Task<Result> CreateLambEar(LambEarCreateCommand cmd)
        { return await mediator.Send(cmd); }


    }
}
